home *** CD-ROM | disk | FTP | other *** search
/ ftp.whtech.com / ftp.whtech.com.tar / ftp.whtech.com / datasheets and manuals / Hardware / WHT / scsi / dsr_sources_2_2001 / gpl24 < prev    next >
Text File  |  2006-10-19  |  6KB  |  288 lines

  1. * GPL Routine >24 - Access Direct Input File
  2. *
  3. * This procedure gets file information from the disk
  4. * and returns it to the caller
  5. *
  6. * Inputs:
  7. *    >834C - SCSI device number and buffer bit
  8. *    >834D - Access code
  9. *    >834E - Pointer to file name
  10. *    >8350 - Additional info
  11. *
  12. * Outputs:
  13. *    >8350 - Error code
  14. *              0 = success
  15. *              non 0 = error
  16. *
  17. GPL24
  18.        ANDI R12,>FF00
  19.        AI   R12,24
  20.  
  21. * Store the scratch pad RAM in a buffer for now
  22.  
  23.        BL   @SAVPAD
  24.  
  25.        BL   @MAKEFN
  26.        BL   @GETFDR
  27.  
  28. * Restore the scratch pad RAM
  29. *
  30.        BL   @RESPAD
  31.  
  32.        CI   R5,0             See if file exists
  33.        JEQ  G24ERR
  34.  
  35. * First check the access code to see if we're transfering
  36. * data or file parameters.
  37. *
  38.        MOVB @>834D,R1
  39.        JNE  GPL24A
  40.  
  41. * We're just transferring file parameters
  42. *
  43.  
  44.        MOVB @>8350,R2        Get pointer to additional info
  45.        SRL  R2,8
  46.        AI   R2,>8300+2
  47.        MOVB @14(R5),*R2+  # of sectors
  48.        MOVB @15(R5),*R2+
  49.        MOVB @12(R5),*R2+  File flags
  50.        MOVB @13(R5),*R2+  # of rec/sec
  51.        MOVB @16(R5),*R2+  EOF offset
  52.        MOVB @17(R5),*R2+  Logical record size
  53.        MOVB @18(R5),*R2+  # of level 3 records
  54.        MOVB @19(R5),*R2+
  55.        MOVB @ZERO,*R2+       MSB of other crap
  56.        MOVB @ZERO,*R2+
  57.        MOVB @ZERO,*R2+       Extended Record Length
  58.        MOVB @ZERO,*R2+
  59.  
  60.        MOVB @ZERO,@>8350     Set success code
  61.        B    @DSRRT
  62.  
  63. * Here we have to read actual data from the file and
  64. * transfer it to the buffer
  65. *
  66.  
  67. GPL24A
  68.  
  69. * Let's start off by copying the FDR to a buffer in another bank
  70. *
  71.        LI   R4,DFDR
  72.        LI   R0,256
  73. GPL24B MOV  *R5+,R3
  74.        LDCR @B02,4
  75.        MOV  R3,*R4+
  76.        LDCR @ZERO,4
  77.        DECT R0
  78.        JNE  GPL24B
  79.  
  80. * Register Usage throughout the rest of the subprogram
  81. *
  82. * R1 - # of sectors left to be read
  83. * R4 - Current AU within file
  84. * R5 - Current sector within AU
  85. * R6 - SCSI ID
  86. * R7, R8 - SCSI sector number to read
  87. * R10 - Pointer to buffer (if CPU RAM)
  88.  
  89.        SRL  R1,8
  90.        MOVB @>834C,R6
  91.        ANDI R6,>0F00
  92.        AI   R6,->0100
  93.  
  94.        MOVB @>8350,R2        Get pointer to additional info
  95.        SRL  R2,8
  96.        AI   R2,>8300
  97.  
  98.        MOV  *R2,R10
  99.  
  100.        MOV  @2(R2),R5        Get sector number
  101.        CLR  R4
  102.  
  103.        MOV  R6,R3
  104.        SRL  R3,8
  105.        SLA  R3,1
  106.        LDCR @B04,4
  107.        DIV  @SAUTBL(R3),R4
  108.  
  109. * Now search through the FDR for actual AU on disk.
  110. *
  111.        LDCR @B02,4
  112.        LI   R3,DFDR+40
  113.  
  114. GPL24D MOV  *R3+,R2
  115.        CI   R4,0
  116.        JEQ  GPL24F
  117. G24DD  C    R2,*R3
  118.        JNE  GPL24E
  119.        INCT R3
  120.        DEC  R4
  121.        JMP  GPL24D
  122.  
  123. G24ERR
  124.        MOVB @B01,@>8350      Set an error code
  125.        B    @DSRRT
  126.  
  127. GPL24E INC  R2
  128.        DEC  R4
  129.        JNE  G24DD
  130.  
  131. GPL24F MOV  R2,R4            R4 now has actual AU
  132.  
  133. * Now lets read the data from disk
  134. *
  135. GPL24H LI   R2,SECBUF
  136.        MOV  R4,R7
  137.        LDCR @B04,4
  138.        MOV  R6,R3
  139.        SRL  R3,8
  140.        SLA  R3,1
  141.        MOV  @SAUTBL(R3),R3
  142.        MPY  R3,R7
  143.  
  144.        A    R5,R8
  145.        JNC  GPL24I
  146.        INC  R7
  147. GPL24I
  148.        SRL  R8,1
  149.        JNC  GPL24J
  150.        AI   R2,>100
  151. GPL24J SRL  R7,1
  152.        JNC  GPL24K
  153.        AI   R8,>8000
  154. GPL24K
  155.  
  156. * Save the contents of scratch pad RAM before
  157. * SCSIRD trashes it
  158.  
  159.        BL   @SAVPAD
  160.  
  161. * If we can transfer all 512 bytes of the SCSI sector, then
  162. * we can use sector I/O to transfer it.
  163. *
  164.        CI   R2,SECBUF
  165.        JNE  GPL24L
  166.        CI   R1,1
  167.        JEQ  GPL24L
  168.        DEC  R3
  169.        C    R3,R5
  170.        JNE  GPL24T
  171. GPL24L
  172.        LDCR @ZERO,4
  173.        BLWP @BANKIT
  174.        DATA SCSIRD
  175.        JNE  G24ERR
  176.  
  177.        BL   @RESPAD
  178.  
  179. * Now we transfer it either to buffer.  The buffer can be in VDP
  180. * RAM or CPU RAM.
  181.  
  182.        LI   R0,256
  183.        MOVB @>834C,R3
  184.        ANDI R3,>8000
  185.        JNE  GPL24N
  186.  
  187. * The buffer is in VDP RAM
  188.  
  189.        ORI  R10,>4000
  190.        SWPB R10
  191.        MOVB R10,@VDPWA
  192.        SWPB R10
  193.        MOVB R10,@VDPWA
  194.        ANDI R10,>3FFF
  195.  
  196. GPL24M MOVB *R2+,@VDPWD
  197.        DEC  R0
  198.        JNE  GPL24M
  199.        AI   R10,256
  200.        JMP  GPL24O
  201.  
  202. GPL24N MOVB *R2+,*R10+
  203.        DEC  R0
  204.        JNE  GPL24N
  205.  
  206. GPL24O INC  R5
  207.        LDCR @B04,4
  208.        MOV  R6,R3
  209.        SRL  R3,8
  210.        SLA  R3,1
  211.        C    R5,@SAUTBL(R3)
  212.        JNE  GPL24Q
  213.  
  214.        CLR  R5
  215.  
  216. * We now loop through the FDR to see if we go to next AU
  217.        LDCR @B02,4
  218.        LI   R3,DFDR+42
  219. GPL24P C    *R3,R4
  220.        JEQ  GPL24S
  221.        AI   R3,4
  222.        CI   R3,DFDR+>100
  223.        JL   GPL24P
  224.  
  225.        INC  R4
  226. GPL24Q
  227.  
  228.        DEC  R1
  229.        JNE  GPL24H
  230.        MOVB R1,@>834D        I don't know if this is right
  231.        MOVB @ZERO,@>8350     Set success code
  232.        LDCR @ZERO,4
  233.        B    @DSRRT
  234.  
  235. GPL24S MOV  @2(R3),R4
  236.        JMP  GPL24Q
  237.  
  238. **
  239. *
  240. *  Here we are going to use SCSI sector I/O to read the data
  241. *
  242. **
  243.  
  244. GPL24T LI   R0,1             Read
  245.        MOVB R6,R0            Set drive number
  246.        ORI  R0,>4000         Use absolute sector size
  247.        MOVB @>834C,R3
  248.        ANDI R3,>8000
  249.        SOC  R3,R0            Set VDP/CPU RAM flag
  250.        MOV  R0,@>834C
  251.        MOV  R10,@>834E       Set buffer address
  252.        MOV  R8,@>8350        Set 32 bit SCSI sector
  253.        MOV  R7,@>8352
  254.  
  255.        LDCR @ZERO,4
  256.        BLWP @BANKIT
  257.        DATA SCSI20
  258.  
  259.        BL   @RESPAD
  260.  
  261.        AI   R10,512          Set new buffer address
  262.        INC  R5
  263.        DEC  R1
  264.        JMP  GPL24O
  265.  
  266. * SAVPAD - Save the contents of scratch pad RAM to
  267. * a buffer in bank 2
  268.  
  269. SAVPAD LDCR @B02,4
  270.        MOV  R10,@POSIAU
  271.        LI   R9,>8300
  272.        LI   R10,G24BUF
  273. SAVPD2 LI   R0,>70
  274. SAVPD1 MOV  *R9+,*R10+
  275.        DECT R0
  276.        JNE  SAVPD1
  277.        MOV  @POSIAU,R10
  278.        LDCR @ZERO,4
  279.        RT
  280.  
  281. * RESPAD - Restore the contents of scratch pad RAM
  282.  
  283. RESPAD LDCR @B02,4
  284.        MOV  R10,@POSIAU
  285.        LI   R10,>8300
  286.        LI   R9,G24BUF
  287.        JMP  SAVPD2
  288.